﻿using HarmonyLib;
using RimWorld;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using System.Reflection.Emit;

namespace SZ.Mech
{
    [HarmonyPatch(typeof(VerbProperties), "CausesExplosion", MethodType.Getter)]
    public static class VerbProperties_Patch
    {

        static bool Prefix(ref VerbProperties __instance, ref bool __result)//这段是爆炸物脱靶屏蔽
        {
            if(__instance.defaultProjectile.thingClass == typeof(SZ_Projectile_Explosive))
            {
                __result = true;
                return false;//是否跳过执行
            }
            return true;//是否继续执行
        }


        //和谐掉报错情况
        //static bool Prefix(ref IEnumerable<string> __result, ThingDef parent)
        //{

        //    __result = new List<string>();
        //    return true; // make sure you only skip if really necessary
        //}

        //public static void Prefix(ref IEnumerable<string> __result, ThingDef parent)
        //{
        //    __result = new List<string>();
        //}

        //public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
        //{
        //    var testG = instructions.ToList();


        //    var instructionsList = new List<CodeInstruction>(instructions);
        //    instructionsList.Add(new CodeInstruction(OpCodes.Ldc_I4, 0));
        //    instructionsList.Add(new CodeInstruction(OpCodes.Ret));
        //    return instructionsList;
        //}
    }
}
